function [V_not_mig, V_mig] = value(V, gb, gtheta, gridb, gridtheta, nb, ntheta, departure, destination, kappa)
    
    V_not_mig(1:nb, 1:ntheta)=0;
    V_mig(1:nb, 1:ntheta)=0;

    for i_b=1:nb
        for i_theta=1:ntheta
            b=gb(departure, i_b, i_theta);
            theta=gtheta(departure, i_b, i_theta);
            m=b*theta;
            V_not_mig(i_b, i_theta)=lin_interpo2(nb, ntheta, gridb, gridtheta, squeeze(V(departure,:,:)), b, theta);

            if m<kappa
                V_mig(i_b, i_theta)=nan;
            else
                b_M=b-kappa;
                m_M=m-kappa;
                if b_M>1e-10
                    theta_M=m_M/b_M;
                else
                    theta_M=1;
                end
                V_mig(i_b, i_theta)=lin_interpo2(nb, ntheta, gridb, gridtheta, squeeze(V(destination,:,:)), b_M, theta_M);
            end
        end
    end

end